module.exports = (app) => {
    const { controller, router } = app;
    // 定义根路由
    router.get('/', controller.home.index);

    // 注册登录接口
    router.post('/register', controller.home.register);
    router.post('/login', controller.home.login);

    // 定义用户相关接口
    router.post('/users', controller.user.create);
    router.get('/users', controller.user.index);
    router.put('/users/:id', controller.user.update);
    router.delete('/users/:id', controller.user.destroy);

    // 博客相关接口（后端路由）
    router.post('/blogs', controller.blog.create);
    router.get('/blogs', controller.blog.index);
    router.get('/blogs/:id', controller.blog.detail);
    router.put('/blogs/:id', controller.blog.update);
    // router.resources('blogs', '/blogs', controller.blog);

    router.post('/comments', controller.comment.create);
    router.get('/blogs/:bid/comments', controller.comment.index);
    router.put('/comments/:id/star', controller.comment.star);
    router.get('/comments/liked', controller.comment.liked);
};
